<div class="x-body">
    <form class="layui-form" data-form='{:request()->url()}'>

        <div class="layui-form-item">
            <label for="pid" class="layui-form-label">
                <span class="x-red">*</span>上级分类
            </label>
            <div class="layui-input-inline">
                <select name="pid" id="pid" name="pid" required="" lay-verify="required">
                    <option value="0">请选择上级分类</option>
                    {volist name="cates" id="c"}
                    <option value="{$c.id}" {if isset($vo.pid) and $vo.pid == $c.id}selected{/if}>{$c._pre}{$c.title}</option>
                    {/volist}
                </select>
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>上级分类
            </div>
        </div>

        <div class="layui-form-item">
            <label for="title" class="layui-form-label">
                <span class="x-red">*</span>分类名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="title" name="title" required="" lay-verify="required"
                value="{$vo.title|default=''}" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>分类名
            </div>
        </div>

        <div class="layui-form-item">
            <label for="seo_keyword" class="layui-form-label">
                <span class="x-red">*</span>SEO关键词
            </label>
            <div class="layui-input-inline">
                <input type="text" id="seo_keyword" name="seo_keyword" required="" lay-verify="required"
                       value="{$vo.seo_keyword|default=''}" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>SEO关键词
            </div>
        </div>

        <div class="layui-form-item">
            <label for="seo_description" class="layui-form-label">
                <span class="x-red">*</span>SEO描述
            </label>
            <div class="layui-input-inline">
                <textarea id="seo_description" name="seo_description" required="" lay-verify="required"class="layui-textarea">{$vo.seo_description|default=''}</textarea>
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>SEO描述
            </div>
        </div>

        <div class="layui-form-item">
            <label for="theme" class="layui-form-label">
                <span class="x-red">*</span>模版
            </label>
            <div class="layui-input-inline">
                <input type="text" id="theme" name="theme" required="" lay-verify="required"
                       value="{$vo.theme|default='index'}" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>模版，默认为index
            </div>
        </div>

        <div class="layui-form-item">
            <label for="content" class="layui-form-label">
                分类内容
            </label>
            <div class="layui-input-block">
                <div id="content_div">{if isset($vo.content)}{$vo.content|raw}{/if}</div>
                <textarea id="content" name="content" hidden></textarea>
            </div>
            <div class="layui-form-mid layui-word-aux">
            </div>
        </div>

        <div class="layui-form-item layui-hide">
        </div>

        <div class="layui-form-item layui-col-xs10 layui-col-xs-offset2">
            {if isset($vo.id)}<input type="hidden" name="id" value="{$vo.id}">{/if}
            <button class="layui-btn" lay-filter="add" lay-submit="">
                确定
            </button>
        </div>
    </form>
</div>
<script>
    $(function () {
        layui.form.render();
        var E = window.wangEditor;
        var editor = new E('#content_div');
        editor.customConfig.menus = [
            'head',  // 标题
            'bold',  // 粗体
            'fontSize',  // 字号
            'fontName',  // 字体
            'italic',  // 斜体
            'underline',  // 下划线
            'strikeThrough',  // 删除线
            'foreColor',  // 文字颜色
            'backColor',  // 背景颜色
            'link',  // 插入链接
            'list',  // 列表
            'justify',  // 对齐方式
            'quote',  // 引用
            'image',  // 插入图片
            'table',  // 表格
            'video',  // 插入视频
            'code',  // 插入代码
            'undo',  // 撤销
            'redo'  // 重复
        ];
        editor.customConfig.uploadImgServer = '{:url("admin/upload/wangeditor")}';
        editor.customConfig.uploadImgMaxLength = 1;
        var $text1 = $('#content')
        editor.customConfig.onchange = function (html) {
            // 监控变化，同步更新到 textarea
            $text1.val(html);
            console.log(html);
        }
        editor.create();
        $text1.val(editor.txt.html())
    });
</script>